package org.example;

import java.util.Random;
import java.util.Scanner;

public class test4 {
    public static void main(String[] args) {
        Random rand = new Random();
        int number = rand.nextInt(100) + 1;
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入你要猜的数字整数：");
            int number2 = sc.nextInt();
            if (number2 == number) {
                System.out.println("猜对了");
                break;
            } else if (number2 > number) {
                System.out.println("猜大了");
            } else if (number2 < number) {
                System.out.println("猜小了");
            }
        }
        //判断旋转字符串
        String strA = "abcde";
        String strB = "abcde";

       /* boolean flag = cherk(strA, strB);
        1.if (flag) {
            System.out.println(true);
        }else {
            System.out.println(false);
        }*/
        //2.
        boolean result=cherk(strA,strB);
        System.out.println(result);
    }

    public static String rotateSring(String str) {
        /*1.String first = str.substring(0, 1);
        String end = str.substring(1);
        return end + first;*/
        //2.
        //将字符串转换为字符数组 str.toCharArray();
        char[]arr = str.toCharArray();
        char first=arr[0];
        for (int i=1;i<arr.length;i++){
            arr[i-1]=arr[i];
        }
        arr[arr.length-1]=first;
        //将字符数组转换为字符串  new String(arr);
        return new String(arr);
    }
   //判断旋转字符串
    public static boolean cherk(String strA, String strB) {
        for (int i = 0; i < strA.length(); i++) {
            strA=rotateSring(strA);
            if (strA.equals(strB)) {
               return true;
            }
        }
            return false;
    }
}